<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 140px;
            margin: 0 auto;
            position: relative;
        }

        img {
            width: 100px;
            height: 140px;

        }

        span {
            position: absolute;
            width: 20px;
            height: 20px;
            background-color: aqua;
            right: 0;
            top: 0;

        }
    </style>
</head>

<body>
    <div>
        <img src="img/sjy.jpg" alt="">
        <span>关</span>
    </div>
    <script>
        let div = document.querySelector('div');
        let span = document.querySelector('span');
        let cc = 0;
        span.onclick = function () {
            //隐藏效果
            div.style.display = 'none';


            //无法执行
            // if (cc = 0) {
            //     div.style.display = 'none';
            //     cc = 1;

            // } else {
            //     div.style.display = 'block';
            //     cc = 0;
            // }

        }
    </script>
</body>

</html>